package com.heima.comment.controller;

import com.heima.comment.model.dto.CommentRepayDto;
import com.heima.comment.model.dto.CommentRepayLikeDto;
import com.heima.comment.model.dto.CommentRepayListDto;
import com.heima.comment.service.ApCommentService;
import com.heima.common.constants.ApCommentConstant;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping(path = "/api/v1/comment_repay")
public class ApCommentRepayController {

    @Resource
    private ApCommentService apCommentService;

    @PostMapping(path = "/save")
    public ResponseResult save(@RequestBody CommentRepayDto dto) {
        return apCommentService.save(dto.getCommentId(), dto.getContent(), ApCommentConstant.COMMENT_TYPE_COMMENT);
    }

    @PostMapping(path = "/load")
    public ResponseResult load(@RequestBody CommentRepayListDto dto) {
        return apCommentService.load(dto.getCommentId(), dto.getMinDate(), dto.getSize());
    }

    @PostMapping(path = "/like")
    public ResponseResult like(@RequestBody CommentRepayLikeDto dto) {
        return apCommentService.like(dto.getCommentRepayId(), dto.getOperation());
    }
}
